<template>
  <div>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td>科室名称</td>
          <td><input type="text" v-model="info.kname" /></td>
        </tr>
        <tr>
          <td>科室人数</td>
          <td><input type="number" v-model="info.knum" /></td>
        </tr>
        <tr>
          <td>科室描述</td>
          <td>
            <textarea v-model="info.kmiao"></textarea>
          </td>
        </tr>
        <tr>
          <td></td>
          <td><input type="button" value="修改" @click="update" /></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { reactive, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import moment from "moment";
const route = useRoute();
const router = useRouter();
let info: any = reactive({
  kid: route.query.kid,
  kname: "",
  knum: 0,
  kmiao: "",
  ljid: 1,
});
onMounted(() => {
  Find();
});
const Find = () => {
  axios({
    url: "/api/Keshi/Find",
    method: "get",
    params: {
      kid: route.query.kid,
    },
  }).then((res) => {
    console.log(res);
    Object.assign(info, res.data);
  });
};
const update = () => {
  axios({
    url: "/api/Keshi/Update",
    method: "post",
    data: info,
  }).then((res) => {
    if (res.data > 0) {
      alert("修改成功");
      router.push("/listkeshi");
      return;
    } else {
      alert("修改失败");
      return;
    }
  });
};
</script>

<style scoped></style>
